/*
Copyright (C) 2011  Christoph Schnack, Berlin (Germany)

This file is part of Tribuit.

    Tribuit is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Tribuit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Tribuit.  If not, see <http://www.gnu.org/licenses/>.
*/
package Wordcheck;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.Vector;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import Settings.*;

/**
 * @author Christoph Schnack
 *
 */
class BottomPanel extends JPanel{
	JLabel wordRangeCounterLabel,correctAnswersCounterLabel;
	Language LANG;
	Settings SET;
	public BottomPanel(Settings set,String vocName, Vector<String> tcs, Vector<String> sections){
		super();
		SET = set;
		LANG = SET.getLanguage();
		this.setBackground(Color.lightGray);
		this.setBorder(BorderFactory.createLineBorder(Color.black, 2));
	//Components
		JLabel headerVoc = new JLabel(vocName);
		headerVoc.setFont(new Font(Font.SERIF,Font.PLAIN,12));
		headerVoc.setToolTipText(vocName);
		WordcheckLabelPanel headerVocPanel = new WordcheckLabelPanel(LANG.getVocabulary()+":",headerVoc);
		//wc-Label
		StringBuffer sb = new StringBuffer();
		for(int i = 0;i<tcs.size();i++){
			if(i == tcs.size()-1) sb.append(tcs.elementAt(i));
			else sb.append(tcs.elementAt(i) + ", ");
		}
		JLabel wcLabel = new JLabel(sb.toString(),JLabel.LEFT);
		wcLabel.setToolTipText(sb.toString());
		wcLabel.setFont(new Font(Font.SERIF,Font.PLAIN,12));
		WordcheckLabelPanel wcPanel = new WordcheckLabelPanel(LANG.getTermclasses()+":",wcLabel);
		//lects-Label
		String sectionsString = "";
		int counter = 1;
		for(String section : sections){
			sectionsString+=section + (counter++<sections.size()?", ":"") ;
		}
		JLabel lectsLabel = new JLabel(sectionsString,JLabel.LEFT);
		lectsLabel.setToolTipText(sectionsString);
		lectsLabel.setFont(new Font(Font.SERIF,Font.PLAIN,12));
		WordcheckLabelPanel lectsPanel = new WordcheckLabelPanel(LANG.getLections()+":",lectsLabel);
		//Counter
		wordRangeCounterLabel = new JLabel("-/-",JLabel.CENTER);
		wordRangeCounterLabel.setFont(new Font(Font.SERIF,Font.PLAIN,15));
		WordcheckLabelPanel testCounterPanel = new WordcheckLabelPanel(LANG.getWord()+":",wordRangeCounterLabel);

		correctAnswersCounterLabel = new JLabel("-",JLabel.CENTER);
		correctAnswersCounterLabel.setFont(new Font(Font.SERIF,Font.PLAIN,15));
		WordcheckLabelPanel tCLPanel = new WordcheckLabelPanel(LANG.getCorrect()+":",correctAnswersCounterLabel);
		
		
		testCounterPanel.setPreferredSize(new Dimension(80,50));
		tCLPanel.setPreferredSize(new Dimension(80,50));
		headerVocPanel.setPreferredSize(new Dimension(130,50));
		lectsPanel.setPreferredSize(new Dimension(190,50));
		wcPanel.setPreferredSize(new Dimension(190,50));
		
		this.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
		this.add(testCounterPanel);
		this.add(tCLPanel);
		this.add(headerVocPanel);
		this.add(lectsPanel);
		this.add(wcPanel);
	}
	
	public void setCorrectAnswersCounterLabel(String txt){
		correctAnswersCounterLabel.setText(txt);
	}
	
	public void setWordRangeCounterLabel(String txt){
		wordRangeCounterLabel.setText(txt);
	}
}